|
|
|
|
|
|
|
Figure 12.26
The Slider lets you graphically enter numeric information. |
|
|
|
|
|
|
|
|
When your users encounter the Slider control in your program, they can click the slider bar and drag it to set a value. They can also use the PageUp, PageDown, and right and left arrow keys to change the value. The information entered by the users is contained in the Value property of the slider. |
|
|
|
|
|
|
|
|
|
The keyboard keys only work on a Slider if it has the focus.  |
|
|
|
|
|
|
|
|
|
|
If the SelectRange property is set to True, the users also can select a range of values by holding down the Shift key while clicking and dragging the slider bar. Unfortunately, this technique is not automatic; it must be managed by your code. You need to add code to the slider's MouseDown event procedure to determine whether users have held down Shift while dragging the slider. If so, your code can set the slider's SelStart property, which defines the starting value of the range, and the SelLength property, which defines the extent of the range. Visual Basic's help system contains a good example under the help topic for the Slider Control. |
|
|
|
|
|
|
|
|
The Color Blender Project |
|
|
|
|
|
|
|
|
To demonstrate the use of the Slider control, you will now build a "color blender" sample project. As you know, Visual Basic forms have a BackColor property, which contains a numeric value representing the form's background color. This sample project uses an array of Slider controls to set the BackColor property. |
|
|
|
|
|
|
|
|
Follow these steps to create the color blender project and add the controls for the project: |
|
|
|
|
|
|
|
|
1. Create a new Standard EXE project. |
|
|
|
|
|
|
|
|
2. Place a check box on the form, name it ckGray, and set the Caption property to Only Shades Of Gray. |
|
|
|
|
|
|
|
|
3. Place a Slider control on the form, and name it sldColor. |
|
|
|
|
|
|
|
|
4. Place a label on the form to the left of the slider, and name it lblColor. |
|
|
|
|
|